package com.eaoa.uc.account.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.eaoa.base.EABaseAction;
import com.eaoa.uc.account.bo.AccountRoleSettingBO;
import com.stony.core.util.CoreUtils;

public class AccountRoleSettingAction extends EABaseAction{

	protected ActionForward doWork(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		String roles = request.getParameter("rolenos");
		Long accountno = CoreUtils.parseLong(request.getParameter("accountno"));
		
		List rolenos = new ArrayList();
		if(StringUtils.isNotBlank(roles)){
			String[] rolees = roles.split(",");
			for(int i=0 ; i<rolees.length; i++){
				String role = rolees[i];
				if(StringUtils.isBlank(role)){
					continue;
				}
				rolenos.add(CoreUtils.parseLong(role));
			}
		}

		new AccountRoleSettingBO(accountno, rolenos).execute();

		return null;
	}
}
